////////////////////////////////////////////////////////////////////////////////
//
//  FLYING KIWI BV
//  Copyright 2010 Flying Kiwi BV
//  All Rights Reserved.
//
//  NOTICE: Flying Kiwi permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package plantool.modules.users.display {
	//--------------------------------------------------------------------------
	//  Imports
	//--------------------------------------------------------------------------
	import flash.events.MouseEvent;
	
	import kiwi.components.ComponentSkin;
	import kiwi.components.skins.IButtonSkin;
	
	//--------------------------------------------------------------------------
	//  [Metadata (Events, Style, Effects etc)]
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  Class declaration
	//--------------------------------------------------------------------------
	public class UserSortingSkin extends ComponentSkin implements IButtonSkin {
		//--------------------------------------------------------------------------
		//Class constants
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class variables
		//--------------------------------------------------------------------------
		private var _width:Number			= 0;
		private var _height:Number			= 0;
		private var _state:int		= 0;
		
		//--------------------------------------------------------------------------
		//Class properties
		//--------------------------------------------------------------------------
		override public function get height():Number 			{ return _height; }
		override public function set height(value:Number):void 	{ _height = value; invalidate(); }
		override public function get width():Number 			{ return _width; }
		override public function set width(value:Number):void 	{ _width = value; invalidate(); }
		
		//--------------------------------------------------------------------------
		//Constructor and Destructor
		//--------------------------------------------------------------------------
		public function UserSortingSkin() {
			super();
		}
		
		public function mouseHandler(event:MouseEvent):void {
			switch (event.type) {
				case MouseEvent.MOUSE_OVER:
					_state = 1;
					break;
				case MouseEvent.MOUSE_OUT:
					_state = 0;
					break;
			}
			
			invalidate();
		}
		
		//--------------------------------------------------------------------------
		//Class methods
		//--------------------------------------------------------------------------
		protected override function update():void {
			graphics.clear();
			
			if (_state == 1) {
				graphics.beginFill(0);
				graphics.drawRect(0, 0, _width, _height);
				graphics.endFill();
				
				graphics.beginFill(0xFFFFFF);
				graphics.lineStyle(0, 0xFFFFFF);
				graphics.moveTo(_width / 2, 2);
				graphics.lineTo(_width - 2, (_height / 2) - 2);
				graphics.lineTo(2, (_height / 2) - 2);
				graphics.lineTo(_width / 2, 2);
				graphics.endFill();
				
				graphics.beginFill(0xFFFFFF);
				graphics.lineStyle(0, 0xFFFFFF);
				graphics.moveTo(_width / 2, _height - 2);
				graphics.lineTo(_width - 2, (_height / 2) + 2);
				graphics.lineTo(2, (_height / 2) + 2);
				graphics.lineTo(_width / 2, _height - 2);
				graphics.endFill();
			}
		}
	}
}